package com.itheima.mapper;

import com.itheima.common.entity.QueryPageBean;
import com.itheima.pojo.CheckGroup;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CheckGroupDao {
    @Insert("INSERT INTO chuanzhi.t_checkgroup (code, name, helpCode, sex, remark, attention) " +
            "VALUES (#{code}, #{name}, #{helpCode}, #{sex}, #{remark}, #{attention})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void add(CheckGroup checkGroup);

    @Insert("insert into chuanzhi.t_checkgroup_checkitem(checkgroup_id, checkitem_id)" + "VALUES  (#{id},#{checkItemId})")
    void setCheckItemCheckGroupId(Integer checkItemId, Integer id);

    @Delete("delete from chuanzhi.t_checkgroup where id=#{id}")
    void delete(Integer id);

    @Delete("delete from chuanzhi.t_checkgroup_checkitem where checkgroup_id=#{id}")
    void deleteAssociation(Integer id);


    @Select("select checkgroup_id from chuanzhi.t_setmeal_checkgroup where setmeal_id=#{id}")
    List<Integer> findCheckGroupIdsBySetmealId(Integer id);

    @Select("select * from chuanzhi.t_checkgroup")
    List<CheckGroup> findPage(QueryPageBean page);


    Integer selectByCheckitemIds(List<Integer> checkitemIds);

    @Delete("delete from chuanzhi.t_setmeal_checkgroup where checkgroup_id=#{id}")
    void deleteCheckGroupSemteal(Integer id);


    @Select("select * from chuanzhi.t_checkgroup")
    List<CheckGroup> findAll();

    @Select("select * from chuanzhi.t_checkgroup where id=#{id}")
    CheckGroup findById(Integer id);

    @Insert("insert into chuanzhi.t_checkgroup_checkitem(checkgroup_id, checkitem_id) values(#{checkGroupId},#{checkitemId})")
    void editCheckGroupCheckItem(Integer checkGroupId, Integer checkitemId);


    void updateCheckGroup(CheckGroup checkGroup);
}
